from django.conf.urls import url
from rest_framework.routers import DefaultRouter, SimpleRouter
from rest_framework_jwt.views import obtain_jwt_token
from meiduo_admin.views import skus, spus, images, specs, options, channel, brands, orders, permission, groups, admin
from .views import statistical, users


urlpatterns = [
    # 登录路由
    url(r'^authorizations/$', obtain_jwt_token),
    # url(r'^authorizations/$', ObtainJSONWebToken.as_view()),
    #----------数据统计----------
    # # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # # 当天注册用户总量统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # # 当天登录用户总量统计
    url(r'^statistical/day_active/$', statistical.UserDayActiveCountView.as_view()),
    # # 当天下单用户总量统计
    url(r'^statistical/day_orders/$', statistical.UserDayOrderCountView.as_view()),
    # # 月增用户总量统计
    url(r'^statistical/month_increment/$', statistical.UserDayMonthCountView.as_view()),
    # # 商品分类访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsCountView.as_view()),
    # ------------------用户管理------------------
    url(r'^users/$', users.UserView.as_view()),
    # ------------------商品规格表管理------------------
    url(r'^goods/simple/$', specs.SpecView.as_view({'get': 'simple'})),
    # ------------------商品图片表管理------------------
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),
    # sku 表管理
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SkuView.as_view({'get': 'specs'})),
    # spu 表管理  获取品牌
    url(r'^goods/brands/simple/$', spus.SpuView.as_view({'get': 'brand'})),
    # 获取1级分类
    url(r'^goods/channel/categories/$', spus.SpuView.as_view({'get': 'channel'})),
    # 获取2级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SpuView.as_view({'get': 'channels'})),
    # 规格选项管理
    url(r'^goods/image/$', spus.SpuView.as_view({'post': 'image'})),
    url(r'^goods/specs/simple/$', options.OptionSimple.as_view()),
    # 频道管理
    url(r'^goods/channels/$',channel.ChannelView.as_view({'get':'list', 'post':'create'})),
    url(r'^goods/channel_types/$',channel.GoodsChannelGroupView.as_view({'get':'list'})),
    url(r'^goods/categories/$', channel.CategoriesView.as_view({'get': 'list'})),
    # 品牌管理
    url(r'^goods/brands/$', brands.BrandlView.as_view({'get': 'list'})),
    url(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),
]
router = DefaultRouter()
router.register('goods/specs', specs.SpecView, base_name='spec')
urlpatterns += router.urls

router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='image')
urlpatterns += router.urls

router = DefaultRouter()
router.register('skus', skus.SkuView, base_name='skus')
urlpatterns += router.urls

router = DefaultRouter()
router.register('goods', spus.SpuView, base_name='goods')
urlpatterns += router.urls

router = DefaultRouter()
router.register('goods', spus.SPUGoodsView, base_name='goods')
urlpatterns += router.urls

router = DefaultRouter()
router.register('specs/options', options.OptionsView, base_name='specs')
urlpatterns += router.urls


router = SimpleRouter()
router.register('goods/channels',channel.ChannelView, base_name='channels')
urlpatterns += router.urls

router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='orders')
urlpatterns += router.urls

router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

router = DefaultRouter()
router.register('permission/admins', admin.AdminView, base_name='admin')
urlpatterns += router.urls